package indi.gtl.superbrain.fragment;

import indi.gtl.superbrain.R;
import indi.gtl.superbrain.widget.shapeview;

import java.util.Timer;
import java.util.TimerTask;

import android.app.ActionBar;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class fragment_a extends Fragment {
	ActionBar actionBar;
	TextView text;
	shapeview view;

	Timer time=new Timer();


	Handler handler=new Handler(){
		public void handleMessage(Message msg) {
			Bundle bundle1=new Bundle();
			bundle1=msg.getData();
			int a=bundle1.getInt("s");
			if(a==1){
				view.reflash_s();
			}else if(a==3){
				view.reflash_a();
			}
		};
		
	};
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
		View view1=inflater.inflate(R.layout.countdown_fragment,null);
	         view= (shapeview)view1.findViewById(R.id.shapeview);
	      time.schedule(new TimerTask() {
	    	  Bundle bundle = new Bundle();
				@Override
				public void run() {
					Message message = new Message();
				    bundle.putInt("s",1);
					message.setData(bundle);
					handler.sendMessage(message);
			  }
			}, 0, 9) ;
	      
	      

		
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				Bundle bundle = new Bundle();
				for(int i=1;i<4;i++){
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					Message message = new Message();
				    bundle.putInt("s",3);
					message.setData(bundle);
					handler.sendMessage(message);
				}
				
			}
		}).start();
			// TODO Auto-generated method stub
			return view1;
		}

}
